package com.dongdongshop.config;

import freemarker.template.Template;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

@Configuration//声明是一个配置类
public class FreemarkerConfig {

    @Value("${myfreemarker.templateLoaderPath}")
    private String path;

    @Value("${myfreemarker.defaultEncoding}")
    private String defaultEncoding;

    @Bean
    public FreeMarkerConfigurer freeMarkerConfigurer(){
        //创建对象
        FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();

        //2.设置模板所在目录
        configurer.setTemplateLoaderPath(path);

        //3.设置编码格式
        configurer.setDefaultEncoding(defaultEncoding);

        return configurer;
    }

}
